package storage

import "reflect"

// Basic 基础配置
type Basic struct {
	Name     string
	Mode     string
	Host     string
	Port     int
	RootURL  string
	Author   string
	Slogan   string
	Posts    string
	Icp      string
	Advert   string
	Category map[string][]string
}

// IsEmpty 验证是否为nil
func (b *Basic) IsEmpty() bool {
	return reflect.DeepEqual(b, Basic{})
}

// IsDebug 是否是debug模式
func (b *Basic) IsDebug() bool {
	return b.Mode != "release"
}

// GetCategoryList 通过一集分类获取子类别
func (b *Basic) GetCategoryList(tp string) []string {
	return b.Category[tp]
}

// IsContainsCategory 获取自类别是否存在
func (b *Basic) IsContainsCategory(tp string, subtp string) bool {
	list := b.Category[tp]
	if list == nil {
		return false
	}

	for _, value := range list {
		if value == subtp {
			return true
		}
	}

	return false
}
